---
description: How to use the TriplitClient transact method to update a Triplit database atomically.
---

# transact

Transactions are a way to group multiple mutations into a single atomic operation. If any part of the mutations fail **on the client**, the entire transaction is rolled back. If the transaction succeeds on the client but fails on the server, it will need to be handled. Read the [event listeners](/client/event-listeners) documentation for more information on how to handle these cases.

A transaction can be created by calling `client.transact()`. For example:

```typescript
await client.transact(async (tx) => {
  await tx.insert('employee', { id: 'Fry', name: 'Philip J. Fry' });
  await tx.insert('employee', { id: 'Leela', name: 'Turanga Leela' });
  await tx.insert('employee', {
    id: 'Bender',
    name: 'Bender Bending Rodriguez',
  });
});
```
